<%--
  Created by IntelliJ IDEA.
  User: Lenovo
  Date: 2025/5/4
  Time: 16:07
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="com.project.DB_User" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%
  String uid = request.getParameter("uid");
  DB_User dbUser = new DB_User();
  List<String> findInput = new ArrayList<>();
  List<String> returnList = new ArrayList<>();
  findInput.add(uid);
  dbUser.find("uid", uid, returnList);
  if (!returnList.isEmpty()) {
    String name = returnList.get(1);
    String pid = returnList.get(2);
    String email = returnList.get(3);
    String phone = returnList.get(4);
    String identity = returnList.get(5);
    String isRegistered = returnList.get(6);
    String password = returnList.get(7);
%>
<!DOCTYPE html>
<html>
<head>
  <title>编辑用户</title>
</head>
<body>
<h2>编辑用户</h2>
<form action="updateUser.jsp" method="post">
  <input type="hidden" name="uid" value="<%= uid %>">
  <label for="name">姓名:</label>
  <input type="text" id="name" name="name" value="<%= name %>" required><br>
  <label for="password">密码:</label>
  <input type="text" id="password" name="password" value="<%= password %>" required><br>
  <label for="pid">身份证号:</label>
  <input type="text" id="pid" name="pid" value="<%= pid %>" required><br>
  <label for="email">邮箱:</label>
  <input type="email" id="email" name="email" value="<%= email %>" required><br>
  <label for="phone">电话:</label>
  <input type="text" id="phone" name="phone" value="<%= phone %>" required><br>
  <label for="identity">身份:</label>
  <select id="identity" name="identity" required>
    <option value="0" <%= "0".equals(identity)? "selected" : "" %>>用户</option>
    <option value="1" <%= "1".equals(identity)? "selected" : "" %>>管理员</option>
  </select><br>
  <label for="is_registered">是否注册用户:</label>
  <select id="is_registered" name="is_registered" required>
    <option value="0" <%= "0".equals(isRegistered)? "selected" : "" %>>否</option>
    <option value="1" <%= "1".equals(isRegistered)? "selected" : "" %>>是</option>
  </select><br>
  <input type="submit" value="更新用户">
</form>
</body>
</html>
<% } else {
  out.println("未找到要编辑的用户");
} %>